<?php echo $html->script('ckeditor/ckeditor'); ?>
<? 	
//$auth=$session->read('Auth');
    
if(!isset($comments)) {
	$comments = $this->requestAction( array( 'controller' => 'comments', 'action' => 'get' ), array( 'pass' => array( $url ) ) );
}
?>
<ul class="list">
	<?php foreach($comments as $comment): ?>
	<li style="margin-bottom:20px">
		<span class="pic" style="float:left;margin-right:20px"><?=$html->image($thumb->image($comment['Comment']['avatar'], 50));?></span>
		<div class="rightCol">
			<span class="fontWhite bold"><?php echo $comment['Comment']['author']; ?></span>
			<div class="infoBar" style="font-size:12px;font-style:italic">on <?php echo date(COMMON_DATE_FORMAT, strtotime($comment['Comment']['modified']));?>
				<?if($comment['Comment']['show']):?>
					<a href="<?=$this->webroot.'comments/delete/'. $comment['Comment']['id']?>"  onclick="return confirm('Are you sure you want to delete this comment?');">Delete</a>
				<?endif;?>
			</div>
			<div style="margin-left:70px">
				<?php echo Sanitize::stripTags($comment['Comment']['message'],'script'); ?>
			</div>
		</div>
	</li>
	<?php endforeach; ?>
</ul>
<div class="postBox">
	<h2>Post a Comment</h2>
	<?php 
	//encode:
	$url_encode = str_replace('/','!',$url);
	echo $this->Form->create('Comment',array( 'controller' => 'comments', 'action' => 'add/'.$url_encode .'#revertBox'));?>
	<ul style="margin-bottom:24px">
		<?if(!$session->read('Auth.User')){?>
			<li>You need to login before you can leave a comment.</li>
		<?
		}
		else{
		?>
			<li><? echo $this->Form->textarea('message', array(
					'id' => 'comment_input_form', 'style' => 'width: 300px;height:150px'));?></li>
			<?=$this->Form->button(__('Save and publish', true), array('class' => 'btnYellow01 btn', 'type' => 'submit', 'style'=>'display:none', 'id'=>'save_publish','name'=>'savePublish')); ?>
			<div class="button_container" style="float:left;margin-top:5px">
				<a href='javascript:void(0)' onclick="$('#save_publish').click(); return false;"><span class="btnBg">Submit</span></a>
			</div>

		<?}?>
		
	</ul>
	
	<?echo $this->Form->end();?>
</div>
